package cn.wolfcode.shop.cloud.mapper;

import cn.wolfcode.shop.cloud.domain.SecKillGood;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SecKillGoodMapper {

    @Select("select * from t_seckill_goods")
    List<SecKillGood> list();


    @Select("select * from t_seckill_goods where id = #{seckillId} ")
    SecKillGood get(Long seckillId);

    //减库存
    @Update("update t_seckill_goods set stock_count = stock_count - 1  where id = #{seckillId} and stock_count> 0")
    int decrCount(Long seckillId);


    //加库存
    @Update("update t_seckill_goods set stock_count = stock_count + 1  where id = #{seckillId} and stock_count> 0")
    int incrCount(Long seckillId);
}
